package com.pdx.service;

import com.pdx.utils.BaiduAiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author PDX
 * @website https://blog.csdn.net/Gaowumao
 * @Date 2022-05-08 18:17
 * @Description
 */
@Service
public class FaceLoginService {

    @Autowired
    private BaiduAiUtils baiduAiUtils;

    //扫描人脸登录
    public String loginByFace(StringBuffer imagebast64) throws Exception{
        String image = imagebast64.substring(imagebast64.indexOf(",") + 1, imagebast64.length());
        String userId = baiduAiUtils.faceSearch(image);
        return userId;
    }
    //扫描人脸注册
    public String registerFace(String userId,StringBuffer imagebast64){
        String image = imagebast64.substring(imagebast64.indexOf(",") + 1, imagebast64.length());
        Boolean isSuccess = baiduAiUtils.faceRegister(userId, image);
        if (isSuccess){
            return "派大星的朋友";
        }
        return null;
    }
}
